<template>
  <div class="login">
    <el-form
      ref="loginRef"
      :model="loginForm"
      :rules="loginRules"
      class="login-form flex-row justify-between"
    >
      <div class="title-logo-lefts flex-col" />
      <div class="title-logo-right flex-col">
        <div
          class="image-text_4 flex-col justify-between page-title"
          style="height: 70px"
        >
          <div style="margin-bottom: 20px">HI,</div>
          <div>环境使用智慧教育学习平台</div>
        </div>

        <div>
          <el-form-item prop="username" class="login-user">
            <el-input
              v-model="loginForm.username"
              type="text"
              size="large"
              auto-complete="off"
              placeholder="用户名"
              maxlength="20"
              oninput="value=value.replace(/[^0-9a-z]/g,'')"
            >
              <template #prefix>
                <el-icon><User /></el-icon>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="password" class="login-pwd">
            <el-input
              v-model="loginForm.password"
              type="password"
              size="large"
              auto-complete="off"
              placeholder="密码"
              maxlength="20"
              @keyup.enter="handleLogin"
            >
              <template #prefix>
                <el-icon><Lock /></el-icon>
              </template>
            </el-input>
          </el-form-item>
          <el-form-item prop="code" v-if="captchaEnabled" class="login-captcha">
            <el-input
              v-model="loginForm.code"
              size="large"
              auto-complete="off"
              placeholder="验证码"
              style="width: 63%"
              @keyup.enter="handleLogin"
            >
              <template #prefix>
                <svg-icon
                  icon-class="validCode"
                  class="el-input__icon input-icon"
                />
              </template>
            </el-input>
            <div class="login-code">
              <img :src="codeUrl" @click="getCode" class="login-code-img" />
            </div>
          </el-form-item>
        </div>
        <div class="login-button-ground" v-if="!imgUrlTwo">
          <el-form-item style="width: 100%">
            <el-button
              :loading="loading"
              size="large"
              type="primary"
              style="width: 100%"
              @click.prevent="handleLogin"
              class="login-button"
            >
              <div>
                <span v-if="!loading" class="login-button-text">登 录</span>
                <span v-else class="login-button-text">登 录 中...</span>
              </div>
            </el-button>
          </el-form-item>
          <div class="title-list">
            <div class="list-item">切换教师端</div>
            <div class="password">
              <div class="list-item">忘记密码</div>
              <div style="margin-left: 10px" class="list-item">免费注册</div>
            </div>
          </div>
        </div>
      </div>
    </el-form>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const loginForm = ref({
  username: "",
  password: "",
  rememberMe: false,
  uuid: "",
});
const codeUrl = ref("");
const loading = ref(false);
// 验证码开关
const captchaEnabled = ref(false);
// 注册开关
const register = ref(false);
function handleLogin() {
  router.replace("/");
}
</script>
<style lang="less" scoped>
.login {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  // height: 100%;
  background-color: rgba(250, 250, 250, 1);
  background-image: url("@/assets/images/login-background.png");
  background-size: cover;
  overflow: hidden;
}
.imgUrl-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  .close {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    color: red;
    opacity: 0.5;
    font-size: 20px;
  }
  img {
    // width: 100%;
    // height: 100%;
  }
}
.justify-between {
  display: flex;
  justify-content: space-between;
}

.flex-row {
  display: flex;
  flex-direction: row;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.image-text_4 {
  width: 315px;
  height: 98px;
  margin: 34px 0 0 43px;
}
.page-title {
  color: #00bfff;
  font-size: 25px;
}

.title-logo {
  width: 315px;
  height: 54px;
  background: url("../assets/images/logo.png") 4px -6px no-repeat;
  background-size: 306px 62px;
}
.title-logos {
  width: 315px;
  height: 50px;
  background: url("../assets/images/tianjinLogo.png") 4px -6px no-repeat;
  background-size: 315px 50px;
}

.title-logo-left {
  border-radius: 3px;
  background-image: url("../assets/images/login-bg.jpg");
  background-position: center center;
  width: 493px;
  height: 546px;
  background-size: 493px 546px;
}

.title-logo-lefts {
  border-radius: 3px;
  background-image: url("@/assets/images/login-bg.jpg");
  background-position: center center;
  width: 493px;
  height: 646px;
  background-size: 493px 646px;
}

.title-logo-right {
  background-color: rgba(255, 255, 255, 1);
  border-radius: 2px;
  width: 400px;
  height: 426px;
  margin-top: 47px;
  display: flex;
  align-items: flex-start;
  justify-content: end;
}
.login-type {
  display: flex;
  align-items: center;
  font-size: 18px;
  justify-content: space-around;
  div {
    padding: 5px;
    border-radius: 5px;
  }
}

.login-form {
  border-radius: 3px;
  width: 893px;
  height: 646px;
  background-color: rgba(255, 255, 255, 1);

  .el-input {
    height: 40px;

    input {
      height: 40px;
    }
  }

  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 0;
  }
}

.login-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}

.login-captcha {
  background-color: rgba(255, 255, 255, 1);
  border-radius: 2px;
  height: 48px;
  width: 320px;
  margin: 16px 0 0 40px;

  .login-code {
    width: 33%;
    height: 40px;
    float: right;

    img {
      cursor: pointer;
      vertical-align: middle;
    }
  }
}

.login-user {
  background-color: rgba(255, 255, 255, 1);
  border-radius: 2px;
  height: 48px;
  width: 320px;
  margin: 15px 0 0 40px;
}

.login-pwd {
  background-color: rgba(255, 255, 255, 1);
  border-radius: 2px;
  height: 48px;
  width: 320px;
  margin: 16px 0 0 40px;
}

.login-button-ground {
  border-width: 0;
  border-radius: 2px;
  height: 48px;
  width: 320px;
  margin: 30px 0 49px 40px;
  .title-list {
    display: flex;
    align-items: center;
    justify-content: space-between;
    div {
      padding-bottom: 3px;
    }
    .password {
      display: flex;
      align-items: center;
      .list-item {
        color: #0000ff;
        border-bottom: 1px solid #0000ff;
      }
    }
    .list-item {
      color: #ff8c00;
      border-bottom: 1px solid #ff8c00;
    }
  }
}

.login-button {
  //background-color: rgba(55, 156, 173, 1);
  height: 48px;
  width: 320px;
}

.login-button-text {
  font-size: 16px;
  font-family: MicrosoftYaHeiUI;
}

.el-login-footer {
  height: 40px;
  line-height: 40px;
  position: fixed;
  bottom: 0;
  width: 100%;
  text-align: center;
  color: #000;
  font-family: Arial;
  font-size: 12px;
  letter-spacing: 1px;
}

.login-code-img {
  height: 40px;
  padding-left: 12px;
}
</style>
